/**
 * 
 */
package whackEm.elements;

import whackEm.V2.WhackEmPanel;
import whackEm.persistent.GameState;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

/**
 * @author caio
 *
 */
public class MoleToHit extends Mole {

	 private boolean changingMoleToHit = false;
	 private int oldMoleHitCounter = 0;
	 private Context context;
	 
	
	 public MoleToHit(int hole, int fps,WhackEmPanel panel,GameState gs) {
		super(hole, fps, panel,gs);
		//setAnimal();
		this.gs = gs;
		gs.setMoleToHit(this.Animal);
		changingMoleToHit = false;		
		this.comingOut = true;
	}

	public void setAnimal(){		
		this.Animal = r.nextInt(2);		
		switch (this.Animal) {
		case RABBIT:
			toDrawBitmap = WhackEmPanel.headRabbit;
			break;
		default:
			toDrawBitmap = WhackEmPanel.headSquirrel;
			break;
		}
		changingMoleToHit = true;
		
	}
	
	
	public void setAnimal(int animal){
		super.setAnimal(animal);
		currentFrame+=2;
		changingMoleToHit = true;
		
	}
	
	public void setDazed(boolean dazed){
		setComingOut(false, 0);
		this.dazed = dazed;
		currentFrame = 0;
	}
	
	public float[] returnRectangle(){
		float[] rect ={
				draw_x,draw_y,draw_x+getWidth(),draw_y+getHeight()
				};
		
		return rect;
	}
	
	
	public void update(long gameTime){ 
		setHole(hole,Animal);
		if (oldMoleHitCounter != gs.getMoleHitCounter() && changingMoleToHit)
			changingMoleToHit = false;
		
		if ((gs.getMoleHitCounter() % (4 + gs.level))   == 0 && !changingMoleToHit) { 			
			setAnimal();
			gs.setMoleToHit(this.Animal);
			
		} 
		
		//put the draw in todrawbitmap
		oldMoleHitCounter = gs.getMoleHitCounter();
	}
}
